$(document).ready(function () {

    $('#pop-wrapper .x-4-move').dragging({
        move: 'both',
        randomPosition: false,
        handler: '.panel-heading'
    });

    $('#pop-wrapper .btn-4-save').off('click').on('click', function () {
        var id = $('#pop-wrapper input:hidden[name="id"]').val();
        var url = 'optionsKey/add.htm';
        if (id) {
            url = 'optionsKey/modify.htm';
        }
        if ($("#pop-wrapper input[name='k']").val() == '') {
            $("#pop-wrapper input[name='k']").focus();
            tipData({message: 'KEY必填', status: 0});
            return;
        }
        if ($("#pop-wrapper input[name='name']").val() == '') {
            $("#pop-wrapper input[name='name']").focus();
            tipData({message: '选项名称必填', status: 0});
            return;
        }
        ajaxSubmitResponseJSON({
            url: url,
            method: 'POST',
            data: $('#pop-wrapper form').serialize(),
            success: function (data) {
                if (data.status == 0) {
                    closeLayer();
                    $('#data-wrapper .btn-4-query').trigger('click');
                }
            }
        });
    });

});